package com.top.up.biz;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.top.up.core.dto.AppConfigDTO;
import com.top.up.entity.AppConfigEntity;
import com.top.up.service.AppConfigService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AppBiz {

    @Autowired
    private AppConfigService appConfigService;

    public AppConfigDTO info(String channelCode){
        AppConfigEntity entity = appConfigService.getOne(new QueryWrapper<AppConfigEntity>().lambda()
                .eq(AppConfigEntity::getChannelCode, channelCode));

        if( entity == null ){
            return null;
        }

        AppConfigDTO configDTO = AppConfigDTO.builder().build();
        BeanUtils.copyProperties(entity, configDTO);
        return configDTO;
    }

}
